//
//  ToolHeader.h
//  Demo
//
//  Created by Kyle on 2022/12/31.
//

#ifndef ToolHeader_h
#define ToolHeader_h

// 打印函数
#ifndef DLog
#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...)
#endif
#endif

//单利宏
#define OBJC_DEF_SINGLETON(className) \
+ (className*) shared##className ;\
+ (instancetype) alloc __attribute__((unavailable("alloc not available, call instance instead")));\
+ (instancetype) new __attribute__((unavailable("new not available, call instance instead")));

#define OBJC_IMPL_SINGLETON(className) \
\
+ (className *)shared##className  { \
static className *shared##className = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
shared##className = [[super alloc] init]; \
}); \
return shared##className; \
}

#endif /* ToolHeader_h */
